package com.banban.user.controller;

import com.banban.user.dto.SessionInfoSelectDTO;
import com.banban.user.service.SessionInfoService;
import com.banban.user.vo.ConversationSelectVO;
import com.banban.user.vo.DataResult;
import com.banban.user.vo.SessionInfoVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/session")
@Slf4j
public class SessionController {

    @Autowired
    private SessionInfoService sessionInfoService;

    /**
     * 查询用户会话信息
     * @param dto
     * @return
     */
    @PostMapping("/selectSessionInfo")
    public DataResult selectSessionInfo(@RequestBody @Valid SessionInfoSelectDTO dto) {
        log.info("查询用户交互记录接口，入参:{}",dto);
        IPage<SessionInfoVO> vo = sessionInfoService.selectSessionInfoPage(dto);
        return DataResult.success(vo);
    }

    /**
     * 根据sessionId查询会话信息
     * @param sessionId
     * @return
     */
    @GetMapping("/selectConversationBySessionId/{sessionId}")
    public DataResult selectConversationBySessionId(@PathVariable("sessionId") String sessionId) {
        log.info("根据sessionId查询会话信息接口，入参:{}",sessionId);
        List<ConversationSelectVO> vo = sessionInfoService.selectConversationBySessionId(sessionId);
        return DataResult.success(vo);
    }
}
